﻿using LibNiconico.NiconicoApi.Extentions;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace LibNiconico.NiconicoApi.Videos.Flv
{
    /// <summary>
    /// ニコニコ動画Flv情報
    /// </summary>
    public sealed class NicoVideoFlvInfo
    {
        private NicoVideoFlvInfo() { }
        
        /// <summary>
        /// メッセージサーバURL
        /// </summary>
        public Uri Ms { get; private set; }

        /// <summary>
        /// スレッドID
        /// </summary>
        public string ThreadId { get; private set; }

        /// <summary>
        /// URL
        /// </summary>
        public Uri Url { get; private set; }

        internal static NicoVideoFlvInfo Parse(QueryStrings query)
        {
            NicoVideoFlvInfo info = new NicoVideoFlvInfo();
            string ms = query["ms"];
            info.Ms =  ms != default(string) ?  new Uri(ms) : null;

            string url = query["url"];
            info.Url = url != default(string) ? new Uri(url) : null;
            
            info.ThreadId = query["thread_id"] ?? "";

            return info;
        }

    }
}
